package com.grq.framework.minio.config;

import com.grq.framework.minio.prop.Minio;
import io.minio.MinioClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.annotation.Resource;

@Configuration
@EnableConfigurationProperties(Minio.class)
public class GrqMinioAutoConfig {

    @Resource
    private Minio minio;

    @Bean
    public MinioClient minioClient() {
        return MinioClient.builder().endpoint(minio.getEndpoint()).credentials(minio.getAccessKey(), minio.getSecretKey()).build();
    }

}
